package org.dfl.log;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

/**
 *
 * @author Lukas
 */
public class Logger {
    
    private static final String FILENAME = "C:/dflPlugin.log";
    
    public static synchronized void log(String str) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(new File(FILENAME), true);
            Date date = new Date();
            writer.write(date.toString() + ": " + str + "\n");
        } catch (IOException ex) {
        } finally {
            try {
                writer.close();
            } catch (IOException ex) {
            }
        }
    }
    
    public static synchronized void logException(Exception exception) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(new File(FILENAME), true);
            Date date = new Date();
            writer.write(date.toString() + ": ");
            exception.printStackTrace(new PrintWriter(writer));
        } catch (IOException ex) {
        } finally {
            try {
                writer.close();
            } catch (IOException ex) {
            }
        }
    }

}
